﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Compilation;
using System.Web;
using NLite.ViewEngines;

namespace NLite.Web.ViewEngines
{
    public class WebFormView:IView
    {
        string VirtualPath;
        public WebFormView(string vp)
        {
            VirtualPath = vp;
        }

        public void Render(System.IO.TextWriter output, object model)
        {
            var page = HttpHandlerFactory.GetHandler(VirtualPath) as ViewPage;
            if (page == null)
                throw new Exception();

            page.Model = model;
            ((IHttpHandler)page).ProcessRequest(HttpContext.Current);
        }
    }
}
